<?php
$lang = LANGUAGE_NONE;


switch ($view_mode){
	case 'full':
		//Calcoclo Menu laterale
		$menu_item = menu_link_get_preferred('node/'.$node->nid);
		$parent = _menu_link_find_parent($menu_item);
		$parameters = array(
		  'active_trail' => array($parent['plid']),
		  'only_active_trail' => FALSE,
		  'min_depth' => $parent['depth']+1,
		  'max_depth' => $parent['depth']+1,
		  'conditions' => array('plid' => $parent['mlid']),
		);
		
		$children = menu_build_tree($parent['menu_name'], $parameters);
		//Fine Calcoclo Menu laterale
		
		//Corpo Right
		$paragrafi = '';
		$menu_paragrafi ='<a class="point selected" id="point_0" href="#slide_0"><span>Introduction</span></a>';
		$tot_par = count($node->field_paragrafo[$lang]);
		if($tot_par == 0){
			$menu_paragrafi ='<a class="point selected last" id="point_0" href="#slide_0"><span>Introduction</span></a>';
		}
		$k = 1;
foreach ($node->field_paragrafo[$lang] as $elem){
			//Recupero value dei campi del paragrafo
			$paragrafo = field_collection_item_load($elem);
			$par_title = (isset($paragrafo->field_titolo_paragrafo[$lang]))?$paragrafo->field_titolo_paragrafo[$lang][0]['value']:'';
			$par_icona = (isset($paragrafo->field_icona[$lang]))?'<div class="icona"><img src="'.file_create_url($paragrafo->field_icona[$lang][0]['uri']).'" /></div>':'';
			$par_descrizione = (isset($paragrafo->field_descrizione[$lang]))?$paragrafo->field_descrizione[$lang][0]['value']:'';
			$par_galleria = '';
			if(isset($paragrafo->field_ct_gallery[$lang])) {
				foreach ($paragrafo->field_ct_gallery[$lang] as $item_gallery) {
					$gallery_node = node_load($item_gallery['nid']);
					$par_galleria .= drupal_render(node_view($gallery_node, 'teaser'));
				}
			}
			//Genero menu con slide
			$last = '';
			if($k == $tot_par){ $last = 'last';}
			$menu_paragrafi .= '<a class="point '.$last.'" id="point_'.$k.'" href="#slide_'.$k.'"><span>'.$par_title.'</span></a>';
			//Creo il paragrafo in html
			$paragrafi .='<div class="slide paragrafo" id="slide_'.$k.'">
						<div class="titolo">
							'.$par_icona.'
							<div class="testo">
								'.$par_title.'
							</div>
						</div>
						<div class="clear"></div>
						<div class="descrizione">
							'.$par_descrizione.'					
						</div>
						'.$par_galleria.'
					</div><!--End Slide '.$k.'-->
					<div class="clear"></div>';
			$k++;
		}
?>

<!-- CORPO CENTRALE -->
<div class="corpo_centrale">
	<!-- LEFT -->
	<div class="left">
		<div class="item-list">
			<?php print drupal_render(menu_tree_output($children)); ?>
		</div>
		<div class="contenuto" id="menu_navigazione" style="display:none;">
			<div class="clear"></div>
			<div class="navigation">
				<?php if(!empty($menu_paragrafi)){ print $menu_paragrafi;  }?>
			</div>
			<div class="clear"></div>
		</div>
	</div>
	<!-- /LEFT -->
	<div class="clear"></div>
	<!-- RIGHT -->
	<div class="right">
		<div class="contenuto">
			<div class="slide paragrafo" id="slide_0">
				<div class="titolo">
					<?php if($node->field_icona[$lang]):?>
					<div class="icona">
						<img src="<?php print file_create_url($node->field_icona[$lang][0]['uri']); ?>" />
					</div>
					<?php endif;?>
					<div class="testo">
						<?php print render($content['field_titolo_sezione']);?>
					</div>
				</div>
				<div class="clear"></div>
				<?php if($node->field_descrizione[$lang]):?>
				<div class="descrizione">
					<?php print render($content['field_descrizione']);?>
				</div>
				<?php endif;?>
				<!-- TEMIZZAZIONE GALLERIA -->				
				<?php
					if($node->field_ct_gallery[$lang]){ 
						print render($content['field_ct_gallery']);
					}
				?>
				<!-- TEMIZZAZIONE GALLERIA -->								
			</div><!--End Slide 0-->
			<div class="clear"></div>
			<?php if(!empty($paragrafi)){ print $paragrafi;  }?>
		</div>
	</div>
	<!-- /RIGHT -->
</div>
<!-- /CORPO CENTRALE -->
<?php 
		break;
	case 'teaser':
		//GESTIONE BUTTON SCOPRI
		global $language;
		$label_scopri = 'DISCOVER';
		if($language->language == 'it'){
			$label_scopri = 'SCOPRI';	
		}
?>	
		<?php if($node->field_icona[$lang]):?>
		<div class="logo">
			<img src="<?php print file_create_url($node->field_icona[$lang][0]['uri']); ?>" />
		</div>
		<?php endif;?>
		<div class="testo">
			<?php if($node->field_titolo_sezione[$lang]):?>
			<div class="titolo">
				<?php print render($content['field_titolo_sezione']);?>
			</div>
			<?php endif;?>
			<?php if($node->field_descrizione[$lang]):?>
			<div class="descrizione">
				 <?php print render($content['field_descrizione']);?>
			</div>
			<?php endif;?>
		</div>
		<div class="scopri">
			<a href="<?php print url('node/'.$node->nid);?>"><?php print $label_scopri; ?></a>
		</div>
		<?php break;		
		}
?>